package com.yun.algorithmproblem.leetcode;

public class Leetcode1328 {

    public String breakPalindrome(String palindrome) {
        if (palindrome.length() == 1) {
            return "";
        }
        char[] chars = palindrome.toCharArray();
        int p = 0, q = palindrome.length() - 1;
        while (p < q) {
            if (chars[p] != 'a') {
                chars[p] = 'a';
                return String.valueOf(chars);
            }
            p++;
            q--;
        }
        chars[chars.length-1]='b';
        return String.valueOf(chars);
    }
}
